package com.hydra.cron.common.utils;

import org.slf4j.Logger;

/**
 * Created by lee on 15/12/24.
 */
public class LogUtil {
    private static final String INFO_FORMAT_START = "###############  ";
    private static final String INFO_FORMAT_END = "  ###############";

    private static final String ERROR_FORMAT_START = "###############  ";
    private static final String ERROR_FORMAT_END = "  ###############";

    private static final String SLOW_METHOD_FORMAT_START = "###############    ";
    private static final String SLOW_METHOD_FORMAT_END = "    ###############";

    public static void logInfo(Logger logger, String message) {
        logger.info(INFO_FORMAT_START + message + INFO_FORMAT_END);
    }

    public static void logError(Logger logger, String message, Throwable e) {
        logger.error(ERROR_FORMAT_START + message + ERROR_FORMAT_END, e);
    }

    public static void logSlowMethod(Logger logger, String name, long time) {
        logger.info(SLOW_METHOD_FORMAT_START + name + " [use time][" + time + "ms]" + SLOW_METHOD_FORMAT_END);
    }
}
